<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="DataLoad.asp"-->
<%
Dim STi , ETi
STi=Timer
%>

<html>
<head>
<title><%=GuildName%> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<%=StylePath%>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<%=StylePath%>/styleplus.js"></script>
<style type="text/css" media="all">

</style>


</head>

<body>

<%
	if CheckAdmin()=False then
		response.redirect "dkplist_"&request("class")&".html"
		response.end
	end if
%>
<div class="header">
<!--#include file="menu.asp"-->
</div>
<div class="main">
			<%
			call dkplist(request("class"))

			%>
</div>
<div class="footer">
<%Response.write "<div>创建时间: "&Now()&" </div>"


%>
</div>
</body>
</html>
<%
Sub dkplist(cid)
	Dim sqlw
	Dim raidth,raidtd,raidtr,colcount,chkNum
	Dim listArr,dkpArr,totalArr,dkptotal,BaseTotal,SpecTotal,FinalTotal,SpecDKP
	Dim profession
	Dim NumberCount
	Dim strjQueryStyle

	Dim SimpleDataArr '简单报表用数组变量

	NumberCount=0
	profession=""
	raidth=""

			select case Request.form("filter")
				case "Warrior"
				sqlw="player_profession='战士' "
				case "Mage"
				sqlw="player_profession='法师' "
				case "Priest"
				sqlw="player_profession='牧师' "
				case "Rogue"
				sqlw="player_profession='盗贼' "
				case "Hunter"
				sqlw="player_profession='猎人' "
				case "Druid"
				sqlw="player_profession='德鲁伊' "
				case "Warlock"
				sqlw="player_profession='术士' "
				case "Paladin"
				sqlw="player_profession='圣骑士' "
				case "Shaman"
				sqlw="player_profession='萨满'"
				case else
				sqlw="1=1"
			end select

	sql="select id,raid_actiontime,raid_name from raid where raid_step=1 and raid_class="&cid&" order by raid_actiontime"
	rs.open sql,conn,1,1
			colcount=rs.recordcount
			Redim listArr(colcount-1)
			Redim dkpArr(colcount-1)
			Redim totalArr(colcount-1)
		for i = 1 to rs.recordcount
			raidth=raidth &"<th><a href='raid_report.asp?id="&rs("id")&"'>"& time_type(rs("raid_actiontime"),1)&"<br>"& left(rs("raid_name"),7) &"</a></th>"&vbCrlf
			listArr(i-1)=rs("id")
		rs.movenext
		next
			raidth=raidth &"<th>S</th><th>总计</th>"
	rs.close
	raidth=raidth&"</tr>"




	'==================
	sql="select id,player_profession,player_name,player_Basedkp from player where "&sqlw&" and player_lastraid > #"&DateADD("d",freezeday,today)&"# order by player_profession desc , player_name"
	'打开会员表
	rs.open sql,conn,1,1

	ReDim SimpleDataArr(rs.recordcount-1,2)
	'遍历会员表
	for z = 1 to rs.recordcount
	chkNum=0
	SpecDKP=0
	raidtd=""
	if profession<>rs("player_profession") then
	profession=rs("player_profession")
	raidtr=raidtr& "<tr class='spaceline'><td colspan='"&UBound(listArr)+5&"'>"&ProPic(rs("player_profession"))&rs("player_profession")&"</td></tr>"&vbCrlf
	end if
	dkptotal=0
		raidtd=raidtd& "	<tr>"
		raidtd=raidtd& "<td><a href='player_detail.asp?id="&rs("id")&"'>"&rs("player_name")&"</a></td>"
		raidtd=raidtd& "<td>"&cPre(BaseDKP(rs("id"),cid))&"</td>"
		chkNum=chkNum+BaseDKP(rs("id"),cid)
		BaseTotal=BaseTotal + BaseDKP(rs("id"),cid)
		dkptotal=dkptotal+BaseDKP(rs("id"),cid)
		sql="select * from dkplist where playerid="&rs("id") '打开DKP表
		rs2.open sql,conn,1,1
		if rs2.bof or rs2.eof then
		else
			for i = 0 to UBound(listArr) '遍历活动ID
				for iy = 1 to rs2.recordcount '遍历DKP记录
					if listArr(i)=rs2("raidid") then '匹配DKP到活动ID
					dkpArr(i)=rs2("dkp")
					totalArr(i)=totalArr(i)+rs2("dkp")
					dkptotal=dkptotal+rs2("dkp")
					end if
				rs2.movenext
				next
				rs2.movefirst
			next
		end if
		FinalTotal=FinalTotal+dkptotal
		rs2.close
		for i = 0 to UBound(dkpArr)
		raidtd=raidtd& "<td "&checkdkp(dkpArr(i))&">"&cPre(dkpArr(i))&"</td>"
		if IsNumeric(dkpArr(i)) then chkNum=chkNum+int(dkpArr(i))+0.113
		dkpArr(i)="-"
		next


		'特殊事件SpecDKP
		sql="select event_object,event_dkp from raid_event where raid_class="&cid&" and (event_object='"&rs("player_name")&"' or event_object like '%|"&rs("player_name")&"|%' )"
		rs2.open sql,conn,1,1
			for ij=1 to rs2.recordcount
				SpecDKP=SpecDKP+rs2("event_dkp")
				rs2.movenext
			next
		SpecTotal=SpecTotal+SpecDKP
		rs2.close

		raidtd=raidtd& "<td>"&cPre(SpecDKP)&"</td>"
		chkNum=chkNum+SpecDKP
		raidtd=raidtd& "<td>"&tcolor(cPre(dkptotal+SpecDKP))&"</td>"
		raidtd=raidtd& "</tr>"&vbCrlf

		Call playerupdate(rs("id"),rs("player_name"),cid,dkptotal+SpecDKP) '更新成员表DKP


		if chkNum<>0 then 
			raidtr=raidtr&raidtd '如果未参见过此类活动就不显示
			NumberCount = NumberCount +1
			SimpleDataArr(z-1,0) = rs("player_name")
			SimpleDataArr(z-1,1) = dkptotal+SpecDKP
			SimpleDataArr(z-1,2) = rs("player_profession")
		end If


	rs.movenext
	next
	rs.close
	raidth="<tr><th>共"&NumberCount&"名成员</th><th>基础</th>" & raidth

	'==================
	'纵向统计
	totaltd=totaltd&"<tr class='sth'><th>统计</th><th>"&cPre(BaseTotal)&"</th>"
	for i=0 to UBound(totalArr)
		totaltd=totaltd&"<th>"&cPre(totalArr(i))&"</th>"
	next
	totaltd=totaltd&"<th>"&cPre(SpecTotal)&"</th><th>"&cPre(FinalTotal+SpecTotal)&"</th></tr>"

	'立刻显示结果
	'Response.write "<table class='dkplist'>"&vbCrlf
	'Response.write raidth&raidtr&raidth&totaltd&vbCrlf
	'Response.write "</table>"


	'Response.write join(listArr)
	
	'生成HTML文件
	if not (Request.form("filter")<>"") then
		htmlhead="<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""><html><head><title>"&GuildName&" - DKP系统</title><script language=""JavaScript"" src=""inc/jquery.js""></script><meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"" /><meta name=""Generator"" content=""EditPlus""><meta name=""Author"" content=""SULei""><meta name=""Keywords"" content=""FSDKP生成文件-DKP详表""><meta name=""Description"" content=""""><link href=""dkptable.css"" rel=""stylesheet"" type=""text/css"" /><style>.ishover {background:#0081db;color:#FFF;}.ishover a {color:#FFF;} .scte {background:#009;color:#FFF;} .scte td {font-size:14px;font-weight:bold;} .scte a {color:#FFF;} </style></head><body>"

		htmlhead=htmlhead&"<div class='header'><h1>"&GuildName&"<span>"&raidclassText(cid)&"分类DKP详表,更新时间:"&Now()&" <a href='default.asp'>返回首页</a></span></h1></div>"
		htmlfooter="<div class='footer'><div>创建时间: "&Now()&"</div></div>"
		strjQueryStyle="<script type=""text/javascript"">$(""tr:even:not(.spaceline)"").addClass(""b"");$(""tr:odd:not(.spaceline)"").addClass(""a"");$(""tr"").toggle(function () {$(this).addClass(""scte"");},function () {$(this).removeClass(""scte"");});$(""tr:not(.spaceline)"").hover(function () {$(this).addClass(""ishover"");},function () {$(this).removeClass(""ishover"");});$(""li"").toggle(function () {$(this).addClass(""scte"");},function () {$(this).removeClass(""scte"");});$(""li"").hover(function () {$(this).addClass(""ishover"");},function () {$(this).removeClass(""ishover"");});</script>"



		'普通版
		dim fso,f
		fso = Server.MapPath("dkplist_"&cid&".html")
		Set f = server.createobject("ADODB.Stream")
		f.Open
		f.Charset = "utf-8"
		f.WriteText = (htmlhead&"<table class='dkplist'>"&raidth&raidtr&raidth&totaltd&"</table>"&htmlfooter&strjQueryStyle&"</body></html>")
		f.SaveToFile fso,2
		f.Close
		set fso = Nothing

		'简化版
		fso = Server.MapPath("dkpsimplelist_"&cid&".html")
		Set f = server.createobject("ADODB.Stream")
		f.Open
		f.Charset = "utf-8"
		f.WriteText = (htmlhead& SimpleFormat(SimpleDataArr) &htmlfooter&strjQueryStyle&"</body></html>")
		f.SaveToFile fso,2
		f.Close
		set fso = Nothing

		'纯文字版
		fso = Server.MapPath("dkpText_"&cid&".html")
		Set f = server.createobject("ADODB.Stream")
		f.Open
		f.Charset = "utf-8"
		f.WriteText = (htmlhead&"<textarea class=""dkptext""  cols=""80"" rows=""36"">"&TextFormat(SimpleDataArr,cid)&"</textarea></body></html>")
		f.SaveToFile fso,2
		f.Close
		set fso = Nothing

		'XML
		fso = Server.MapPath("dkplist_"&cid&".xml")
		Set f = server.createobject("ADODB.Stream")
		f.Open
		f.Charset = "utf-8"
		f.WriteText = (XMLFormat(SimpleDataArr))
		f.SaveToFile fso,2
		f.Close
		set fso = Nothing
		
	end If


	'更新分类更新日期
	conn.execute("update raid_class set closing_date=#"&Now()&"# where id="&cid)

	'
	Call workcomplete(cid)

End Sub

Sub workcomplete(cid)
	response.write "<div class='message'>"
	response.write "<h3>更新完成</h3>"
	response.write "<div>"
	response.write "<a class='abtn' href='dkplist_"&cid&".html'>详细报表</a> <a class='abtn' href='dkpsimplelist_"&cid&".html'>简单列表</a> <a class='abtn' href='dkpText_"&cid&".html'>文本格式</a>"
	response.write "<br><br><br><a href='.'>返回首页</a>"
	response.write "</div>"
	response.write "</div>"
End Sub

Function tcolor(t)
	if t>0 and t<50 then
		tcolor="<span class='ta'>"&t&"</span>"
	elseif t>49 and t<100 then
		tcolor="<span class='taa'>"&t&"</span>"
	elseif t>99 then
		tcolor="<span class='taaa'>"&t&"</span>"
	elseif t<0 and t>-20 then
		tcolor="<span class='tb'>"&t&"</span>"
	elseif t<-20 and t>-100 then
		tcolor="<span class='tbb'>"&t&"</span>"
	elseif t<-100 then
		tcolor="<span class='tbbb'>"&t&"</span>"
	else
		tcolor=t
	end if
End Function

Function checkdkp(dkp)
	if dkp<>"" and dkp<>"-" then
	checkdkp=" class='iFull' "
	else
	checkdkp=""
	end if
End Function

Sub playerupdate(pid,pname,cid,dkp)
	sql="select top 1 * from player_dkp where player_id="&pid&" and raid_class="&cid
	rs2.open sql,conn,1,1
		if rs2.bof or rs2.eof then
		'创建新记录
			response.write "创建新成员DKP:"&pname&"<br>"
			conn.execute("INSERT INTO player_dkp (player_id,player_name,raid_class,player_dkp,player_Basedkp) values ('"&pid&"','"&pname&"',"&cid&",0,0)")	
		else
			conn.execute("update player_dkp set player_dkp="&dkp&" where raid_class="&cid&" and player_id="&pid)
		end if
	rs2.close
End Sub

function selectpro()
	stext=stext& "<form method='post' action=''><select name='filter' onChange='javascript:submit();'>"
	stext=stext& "<option value=''>过滤</option>"
	stext=stext& "<option value='All'>ALL</option>"
	stext=stext& "<option value='Warrior'>Warrior</option>"
	stext=stext& "<option value='Priest'>Priest</option>"
	stext=stext& "<option value='Mage'>Mage</option>"
	stext=stext& "<option value='Paladin'>Paladin</option>"
	stext=stext& "<option value='Hunter'>Hunter</option>"
	stext=stext& "<option value='Warlock'>Warlock</option>"
	stext=stext& "<option value='Druid'>Druid</option>"
	stext=stext& "<option value='Rogue'>Rogue</option>"
	stext=stext& "<option value='Shaman'>Shaman</option>"
	stext=stext& "</select></form>"
	selectpro=stext
end function

Function SimpleFormat(t)
	SimpleFormat = SimpleFormat + "<ul class='simplelist'>"
	For iig = 0 To UBound(t,1)
	If t(iig,0)<>"" Then 
		SimpleFormat = SimpleFormat + "<li><span>"&cPre(t(iig,1))&"</span>"&ProPic(t(iig,2))&t(iig,0)&"</li>"
	End If
	Next
	SimpleFormat = SimpleFormat + "</ul>"
End Function

Function XMLFormat(t)
	XMLFormat = XMLFormat + "<?xml version=""1.0"" encoding=""UTF-8""?><dkplist>"
	For iig = 0 To UBound(t,1)
	If t(iig,0)<>"" Then 
		XMLFormat = XMLFormat + "<dkp name="""&t(iig,0)&""" dkp="""&cPre(t(iig,1))&""" />"
	End If
	Next
	XMLFormat = XMLFormat + "</dkplist>"
End Function


Function TextFormat(t,cid)
	TextFormat = TextFormat + GuildName&"公会 "&raidclassText(cid)&"DKP统计表 更新于:"&Date()&vbCrlf
	TextFormat = TextFormat + "-------------------------------------------------------------"&vbCrlf
	For iig = 0 To UBound(t,1)
	If t(iig,0)<>"" Then 
		TextFormat = TextFormat + Balm(t(iig,2),10)&Balm(t(iig,0),24)&cPre(t(iig,1))&vbCrlf
	End If
	Next
	TextFormat = TextFormat + "-------------------------------------------------------------"&vbCrlf
	TextFormat = TextFormat + "完成　　"&Date()&" 　由FSDKP系统生成"&vbCrlf
End Function

Function Balm(txt,tlong) '排版补白 文字,需要长度
	Balm = txt & String( Abs(tlong - cint(len2(txt)) )*0.5,"　")
End Function




ETi=Timer()

%>